'\" te
.\" Copyright 1989 AT&T.  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH MLOCKALL 3C "Mar 22, 2004"
.SH NAME
mlockall, munlockall \- lock or unlock address space
.SH SYNOPSIS
.LP
.nf
#include <sys/mman.h>

\fBint\fR \fBmlockall\fR(\fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBmunlockall\fR(\fBvoid\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBmlockall()\fR function locks in memory all pages mapped by an address
space.
.sp
.LP
The value of \fIflags\fR determines whether the pages to be locked are those
currently mapped by the address space, those that will be mapped in the future,
or both:
.sp
.in +2
.nf
       \fBMCL_CURRENT\fR  Lock current mappings
       \fBMCL_FUTURE\fR   Lock future mappings
.fi
.in -2

.sp
.LP
If \fBMCL_FUTURE\fR is specified for \fBmlockall()\fR, mappings are locked as
they are added to the address space (or replace existing mappings), provided
sufficient memory is available. Locking in this manner is not persistent across
the \fBexec\fR family of functions (see \fBexec\fR(2)).
.sp
.LP
Mappings locked using \fBmlockall()\fR with any option may be explicitly
unlocked with a \fBmunlock()\fR call (see \fBmlock\fR(3C)).
.sp
.LP
The  \fBmunlockall()\fR function removes address space locks and locks on
mappings in the address space.
.sp
.LP
All conditions and constraints on the use of locked memory that apply to
\fBmlock\fR(3C) also apply to \fBmlockall()\fR.
.sp
.LP
Locks established with \fBmlockall()\fR are not inherited by a child process
after a  \fBfork\fR(2) call, and are not nested.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, the  \fBmlockall()\fR and  \fBmunlockall()\fR
functions return \fB0\fR.  Otherwise, they return  \fB\(mi1\fR and set
\fBerrno\fR to indicate the error.
.SH ERRORS
.sp
.LP
The \fBmlockall()\fR and \fBmunlockall()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 10n
Some or all of the memory in the address space could not be locked due to
sufficient resources. This error condition applies to \fBmlockall()\fR only.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIflags\fR argument contains values other than \fBMCL_CURRENT\fR and
\fBMCL_FUTURE\fR.
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
The {\fBPRIV_PROC_LOCK_MEMORY\fR} privilege is not asserted in the effective
set of the calling process.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR exec (2),
.BR fork (2),
.BR memcntl (2),
.BR mmap (2),
.BR mlock (3C),
.BR plock (3C),
.BR sysconf (3C),
.BR attributes (7),
.BR standards (7)
